//
//  Contact.m
//  OC05_数组_字典_集合
//
//  Created by dllo on 16/3/1.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "Contact.h"

@implementation Contact

#pragma mark - 自定义初始化姓名 电话号
- (instancetype)initWithName:(NSString *)name phoneNumber:(NSString *)phoneNumber {
    self = [super init];
    if (self) {
        _name = name;
        _phoneNumber = phoneNumber;
        
        /** 根据name, 获取其首字母, 然后转换为大写, 最后赋值给_groupName实例变量 */
        _groupName = [name substringToIndex:1].uppercaseString;
    }
    return self;
}

#pragma mark - 构造器
+ (instancetype)contactWithName:(NSString *)name phoneNumber:(NSString *)phoneNumber{
    return [[Contact alloc] initWithName:name phoneNumber:phoneNumber];
}

#pragma mark - 显示联系人信息
- (void)info
{
    NSLog(@"name:%@, phoneNumber:%@, gender:%@, address:%@, age:%@", _name, _phoneNumber, _gender, _address, _age );
}



- (NSString *)description
{
    return [NSString stringWithFormat:@"name: %@, phone: %@, sex: %@, address: %@, group: %@, age: %@", self.name, self.phoneNumber, self.gender, self.address, self.groupName, self.age];
}

@end
